package com.bw.employee.controller;

import com.bw.employee.service.TbEmployeeService;
import com.bw.result.ResultVo;
import com.bw.vo.IdVo;
import com.bw.vo.TbEmployeeSearchVo;
import com.bw.vo.TbEmployeeVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuzhihao
 * @version 1.0
 * @description: TODO
 * @date 2023/11/10 21:02:36
 */
@RestController
@Slf4j
@RequestMapping("/employee")
public class TbEmployeeController {

    @Autowired
    private TbEmployeeService tbEmployeeService;

    /**
     * @description : //TODO 添加员工
     * @param tbEmployeeVo
     * @return : com.bw.result.ResultVo
     * @author : liuzhihao
     * @date : 2023/11/10 21:58:19
     */
    @PostMapping("/add")
    public ResultVo add(@RequestBody TbEmployeeVo tbEmployeeVo){
        return tbEmployeeService.add(tbEmployeeVo);
    }

    /**
     * @description : //TODO 编辑员工
     * @param tbEmployeeVo
     * @return : com.bw.result.ResultVo
     * @author : liuzhihao
     * @date : 2023/11/10 22:02:54
     */
    @PostMapping("/update")
    public ResultVo update(@RequestBody TbEmployeeVo tbEmployeeVo){
        return tbEmployeeService.updateByVo(tbEmployeeVo);
    }

    /**
     * @description : //TODO 通过id删除
     * @param idVo
     * @return : com.bw.result.ResultVo
     * @author : liuzhihao
     * @date : 2023/11/10 22:04:09
     */
    @PostMapping("/delete")
    public ResultVo delete(@RequestBody IdVo idVo){
        return tbEmployeeService.delete(idVo);
    }

    /**
     * @description : //TODO 员工姓名+手机号精准+分页查询
     * @param tbEmployeeSearchVo
     * @return : com.bw.result.ResultVo
     * @author : liuzhihao
     * @date : 2023/11/11 8:46:29
     */
    @PostMapping("/listBySearchVo")
    public ResultVo listBySearchVo(@RequestBody TbEmployeeSearchVo tbEmployeeSearchVo){
        return tbEmployeeService.listBySearchVo(tbEmployeeSearchVo);
    }
}
